<?php 
echo $this->Html->css('jquery-ui/jquery-ui-1.10.4.custom.min');
echo $this->Html->script('bxslider/jquery.bxslider.min');
echo $this->Html->css('bxslider/jquery.bxslider');
$price = array();
foreach($tp as $p){
	$price[$p['showtime']][] = $p;
}
ksort($price);
$weeknames = array('日','一','二','三','四','五','六');
?>
<ul>
	<li style = 'height:16px;'>
 		<span>开始时间:</span>
 		<div id = 'price-view' style = 'width:250px;height:16px;float:left'>
			<table style = 'width:100%;'>
				<tr>
		            <td>
		        		<a id = 'slider-prev' href = 'javascript:;'>&nbsp;&nbsp;</a>
		            </td>
		            <td>
		                <ul id = 'slider-price'>
		                	<?php foreach ($price as $tk => $tv):?>
                            		<li data-class = 'pg-<?php echo md5($tk)?>'>
                                		<em class="shijian"><?php echo date(str_replace('w', $weeknames [date('w', strtotime($tk))], 'Y年m月d日 周w H:i'),strtotime($tk))?></em>
                                	</li>
							<?php endforeach;?>
						</ul>
		            </td>
		            <td>
		            	<a id = 'slider-next' href = 'javascript:;'>&nbsp;&nbsp;</a>
		        	</td>
				</tr>
		 	</table>
		</div>
    </li>
    <li id = 'price-hole'>
		<span>选择价格:</span>
		<?php $i=0;
			foreach ($price as $tk => $tv):?>
			<p class = 'pg-<?php echo md5($tk)?>' <?php echo ($i++>0)?'style=display:none':''; ?>>
				<?php foreach ($tv as $p):?>
					<?php if($p['ticket_price_state_id'] == 1):	//正常?>
					<a href="javascript:;" onclick = 'CART.selPrice(<?php echo $p['id']?>,this)'><?php echo $p['price'];echo ($p['description'])?"({$p['description']})":false;?></a>
					<?php elseif($p['ticket_price_state_id'] == 2): //缺票?>
					<a href="javascript:;"  class = 'sold_lack' data-showtime = "<?php echo date(str_replace('w', $weeknames [date('w', strtotime($p['showtime']))], 'Y年m月d日 周w H:i'),strtotime($p['showtime']))?>" title = '票品暂缺,您可以点击登记试试运气' onclick = 'CART.askfor(<?php echo $p['id']?>,this)'><?php echo $p['price'];echo ($p['description'])?"({$p['description']})":false;?></a>
					<?php elseif($p['ticket_price_state_id'] == 3): //卖完?>
					<a href="javascript:;" class = 'sold_out' title = '该门票已经售罄'><?php echo $p['price'];?></a>
					<?php else:?>
					<a href="javascript:;" class = 'sold_stop' title = '该门票已经停售'><?php echo $p['price'];?></a>
					<?php endif;?>
                <?php endforeach;?>
	        </p>	
		<?php endforeach;?>
     </li>
     <div class="clear"></div>
	<li>
        <span>购买数量:</span>
        <a href="javascript:;" onclick = 'CART.changeCount(-1)' class="jian"></a>
        <input type="text" class="txt" id = 'ticket_count' value = '1'>
        <a href="javascript:;" onclick = 'CART.changeCount(1)'  class="jia"></a>
        <input type="hidden" id="ticket_id" value = "<?php echo $ticket_id?>">
        <input type="hidden" id="ticket_price_id" value = "">
		
    </li>
    <div class="clear"></div>
    <li class="gmai">
    	<?php if($ed < date('Y-m-d')):?>
    		<a href="javascript:;" class="ticket_time_out">票品已下架</a>
    	<?php else:?>
    	<a href="javascript:;" class="ljgm" onclick='CART.ViewAddCart(1)'>立即购买</a>
    	<!-- 
    	<a href="javascript:;" class="ljgm buy_etitcke" title = '购买电子票 享更多优惠' onclick='CART.ViewAddCart(3)'>电子票</a>
    	 -->
        <a href="javascript:;" class="jiaru" onclick = 'CART.ViewAddCart(2)'>加入购物车</a>
        <?php endif;?>
    </li>
	<div class="clear"></div>
</ul>
<div id = 'dialog' style="display:none;">
	<div class="djTop">
    	<p>. 此价格暂时缺货，您可以进行缺货登记。</p>
        <p>. 我们会记录您的基本信息，待到货时我们会第一时间通知您。</p>
        <p>. 若始终缺货，秦文票务网将不做另行通知。</p>
    </div>
    <div class="djFoot">
    	<?php echo $this->Form->create('TicketBook',array('id'=>'ticket_book','onsubmit'=>'return false'))?>
    	<ul>
        	<li>
            	<span>登记商品：</span>
                <p id = 'ticket_price_show_title'></p>
            </li>
            <li>
            	<span>姓名：</span>
                <?php 
                if(!empty($Auth)):
                echo $this->Form->input('name',array('class'=>"shuru",'style'=>"width:70px;",'value'=>$Auth['name'],'div'=>false,'label'=>false));
                else:
                echo $this->Form->input('name',array('class'=>"shuru",'style'=>"width:70px;",'value'=>'','div'=>false,'label'=>false));
                endif;
                ?>
            </li>
            <li>
            	<span>数量：</span>
                <?php 
                	if(!empty($Auth)):
                	echo $this->Form->input('user_id',array('type'=>"hidden",'value'=>$Auth['id']));
                	else:
                	echo $this->Form->input('user_id',array('type'=>"hidden",'value'=>''));
                	endif;
            		echo $this->Form->input('ticket_id',array('type'=>"hidden",'value'=>$ticket_id));
               		echo $this->Form->input('ticket_price_id',array('type'=>"hidden",'id'=>'ticket_price_ask_id','value'=>$ticket_id));
                	echo $this->Form->input('count',array('class'=>"shuru",'default'=>1,'style'=>'width:70px;','div'=>false,'label'=>false));
                ?>
            </li>
            <li>
            	<span>手机号码：</span>
                <?php echo $this->Form->input('phone',array('class'=>"shuru",'div'=>false,'label'=>false))?>
            </li>
            <li>
            	<span>留言：</span>
            	<?php echo $this->Form->input('remark',array('style'=>"width:200px;height:50px;resize:none",'type'=>'textarea','div'=>false,'label'=>false))?>
            </li>
             <li>
                <a href="javascript:;" onclick = "CART.asksubmit()" class="queding">确定</a>
            </li>
        </ul>
        <?php echo $this->Form->end();?>
    </div>
</div>
	<script>
	$(document).ready(function(){
		  $('#slider-price').bxSlider({
			  nextSelector: '#slider-next',
			  prevSelector: '#slider-prev',
			  nextText: '&nbsp;',
			  prevText: '&nbsp;',
			  pager:false,
			  onSlideAfter:function($slideElement, oldIndex, newIndex){
				  var pclass= '.'+$slideElement.data('class');
				  jQuery('#price-hole p').hide();
				  jQuery('#price-hole').find(pclass).show();
			  }
		  });
		    $( '#price-hole a,.buy_etitcke' ).tooltip({
		      position: {
		        my: "center bottom-5",
		        at: "center top",
		      }
		    });
		});
	</script>